<script setup lang="ts">
import Versions from './components/Versions.vue'

const ipcHandle = () => window.electron.ipcRenderer.send('ping')

const levels = ['info', 'warn', 'error']
const log = () => window.electron.ipcRenderer.send('log', { level: levels[Math.round(Math.random() * (levels.length - 1))], message: '当前时间: ' + Date.now() })
const setting = () => window.electron.ipcRenderer.send('setting', { date: new Date() })
const readSetting = async () => alert(await window.electron.ipcRenderer.invoke('readSetting'))

</script>

<template>
  <img alt="logo" class="logo" src="./assets/electron.svg" />
  <div class="creator">Powered by electron-vite</div>
  <div class="text">
    Build an Electron app with
    <span class="vue">Vue</span>
    and
    <span class="ts">TypeScript</span>
  </div>
  <p class="tip">Please try pressing <code>F12</code> to open the devTool</p>
  <div class="actions">
    <div class="action">
      <a href="https://electron-vite.org/" target="_blank" rel="noreferrer">Documentation</a>
    </div>
    <div class="action">
      <a target="_blank" rel="noreferrer" @click="ipcHandle">Send IPC</a>
    </div>
    <div class="action">
      <a target="_blank" rel="noreferrer" @click="log">记录日志</a>
    </div>
    <div class="action">
      <a target="_blank" rel="noreferrer" @click="setting">保存配置</a>
    </div>
    <div class="action">
      <a target="_blank" rel="noreferrer" @click="readSetting">读取配置</a>
    </div>
  </div>
  <Versions />
</template>
